home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue50 / HTML / usXMLParser.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1999-08-01  |  1.5 KB  |  62 lines

  1. unit usXMLParser;
  2.  
  3. interface
  4.  
  5. uses
  6.   Classes;
  7.  
  8. type
  9.   TusXMLElement = class;
  10.   TusXMLAttribute = class;
  11.   TusXMLAttributes = class;
  12.  
  13.   TusXMLAttribute = class
  14.   private
  15.     FName: string;
  16.     FValue: string;
  17.   public
  18.     property Name: string read FName write FName;
  19.     property Value: string read FValue write FValue;
  20.   end;
  21.  
  22.   TusXMLAttributes = class(TPersistent)
  23.   private
  24.     FList: TList; { List of TusXMLAttribute instances }
  25.   protected
  26.     function GetAttribute(aIndex: Integer): TusXMLAttribute;
  27.     function GetCount: Integer;
  28.   public
  29.     constructor Create;
  30.     destructor Destroy; override;
  31.     procedure Add(aItem: TusXMLAttribute);
  32.     procedure Assign(aSource: TPersistent); override;
  33.     function AttributeByName(aName: string): TusXMLAttribute;
  34.     procedure Clear;
  35.     function Value(aName: string): string;
  36.     property Count: Integer read GetCount;
  37.     property Items[aIndex: Integer]: TusXMLAttribute read GetAttribute; default;
  38.   end;
  39.  
  40.   TusXMLElement = class
  41.   private
  42.     FAttributes: TusXMLAttributes;
  43.     FData: string;
  44.     FTagName: string;
  45.     FParent: TusXMLElement;
  46.   public
  47.     property Attributes: TusXMLAttributes read FAttributes;
  48.     property Data: string read FData write FData;
  49.     property TagName: string read FTagName write FTagName;
  50.     property Parent: TusXMLElement read FParent;
  51.   end;
  52.  
  53.   TusXMLDocument = class
  54.   public
  55.     property Count: Integer;
  56.     property Items[aIndex: Integer]: TusXMLElement;
  57.   end;
  58.  
  59. implementation
  60.  
  61. end.
  62.